<?php
class BrandControl extends AuthControl{
	public function index(){
		$data = catched('brand');
		$this->assign('data',$data);
		$this->display();
	}
	public function add(){
		if(IS_POST){
			$model = K('Brand');
			if($model->addBrand()){
				$this->success('品牌添加成功',U('index'));
			}else{
				$this->error($model->error);
			}
		}else{
			$this->display();
		}
	}
	public function save(){
		$model = K('Brand');
		$bid = Q('bid');
		if(IS_POST){
			if($model->saveBrand($bid)){
				$this->success('品牌更新成功',U('index'));
			}else{
				$this->error($model->error);
			}
		}else{
			$brand = $model->find("bid=".$bid);
			$this->assign('brand',$brand);
			$this->display();
		}
	}
	public function updateCache(){
		$model = K('Brand');
		if($model->updateCache()){
			$this->success('更新缓存成功',U('index'));
		}else{
			$this->error($this->error);
		}
	}
}
?>
